package com.atguigu.spzx.product.controller;

import com.atguigu.spzx.model.common.Result;
import com.atguigu.spzx.model.vo.h5.CategoryVo;
import com.atguigu.spzx.product.service.CategoryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Tag(name = "用户端分类模块")
//@CrossOrigin(originPatterns = "*" , allowCredentials = "true")
@RequestMapping("/api/product/category")
public class CategoryController {
    @Resource
    CategoryService categoryService;
    @Operation(summary = "查询分类嵌套列表")
    @GetMapping("/findCategoryTree")
    public Result findCategoryTree(){
        //查询组装好的 1,2,3级分类数据的集合
        List<CategoryVo> parents = categoryService.findCategoryTree();

        return Result.ok().data(parents);
    }
}
